import {Component, ElementRef, OnInit} from '@angular/core';
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
import {Log} from "../log/log";
import {LogService} from "../log/log.service";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";

function $http(param: {headers: {"Content-Type": undefined}; method: string; data: FormData; url: string}) {

}

@Component({
  selector: 'app-index',
  templateUrl: './index.component.html',
  styleUrls: ['./index.component.css']
})


export class IndexComponent implements OnInit {
  // url="http://localhost:8080/monitor"
  // url="./assets/monitor.html"
  url="./assets/player.html"
  // url="./assets/players.html"
  // url="./assets/test.html"
  base64Url:string='';
  getBase64Url = 'localhost:8080/oo';
  iframeUrl:SafeResourceUrl;
  num:number=11;
  pictureType:string=".jpg";
  imgPath:string="./assets/"+this.num+this.pictureType;

  constructor(private sanitizer:DomSanitizer,
              private logService:LogService,
              private http: HttpClient) {
    this.iframeUrl=this.sanitizer.bypassSecurityTrustResourceUrl(this.url)
  }

  ngOnInit(): void {
  }

  logs:Log[]=[]
  setLogs(){
    this.logService.httpGetLogs().subscribe((data:Log[])=>this.logs=data);
  }

  getBase64():Observable<string>{
    return  this.http.get<string>(this.getBase64Url)
  }

  setBase64(){
    this.getBase64().subscribe((data:string)=>this.base64Url=data)
    console.log(this.base64Url)
  }

}
